package com.liuyongyi.livepush.base;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.util.DisplayMetrics;
import android.view.WindowManager;
import android.widget.Toast;


/**
 * Created by android on 2017/12/26.
 */

public class BaseActivity extends Activity {
    private WindowManager manager;
    @Override
    public void onCreate( Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

   protected void showToast(String message){
       Toast.makeText(this,message,Toast.LENGTH_SHORT).show();
   }

    protected int getScreenWidth(){
        if(manager == null){
            manager = (WindowManager)getSystemService(Context.WINDOW_SERVICE);
        }
        int width = manager.getDefaultDisplay().getWidth();
        return width;
    }
    protected int getScreenHeight(){
        if(manager == null){
            manager = (WindowManager)getSystemService(Context.WINDOW_SERVICE);
        }
        int height = manager.getDefaultDisplay().getHeight();
        return height;
    }
    //获取屏幕的密度
    protected int getHdpi(){
        int mScreenDensity;
        DisplayMetrics metrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(metrics);
        mScreenDensity = metrics.densityDpi;
        return mScreenDensity;
    }
}
